import page4Fn from './page4/page4Module';
import layerApp from './router/layer.router';
// import ueditorApp from './router/ueditor.router';
import graphApp from './router/graph.router';
import lineApp from './router/line.router';
import ztreeApp from './router/ztree.router';
import formApp from './router/form.router';
import circleApp from './router/circle.router';
import radarApp from './router/radar.router';
import selfTable from './router/selfTable.router';
import ngRepeat from './router/ng/repeat.router';
import timeLine from './router/component/timeLine.router';
export default (ngModule, Angular) => {
    ngModule.config(['$stateProvider', '$locationProvider', '$urlRouterProvider', function ($stateProvider, $locationProvider, $urlRouterProvider) {
        //$locationProvider.html5Mode(true);
        // $locationProvider.hashPrefix('!');

        $urlRouterProvider.otherwise('/feng/page1');
        $urlRouterProvider.when('', '/feng');
        $stateProvider.state('feng', {
            url: '/feng',
            template: require('./main.html'),
            abstract: true,
            // templateUrl: './main.html',
            controller: 'mainCtrl',
            controllerAs: 'test'
        }).state('feng.page1', {
            url: '/page1',
            template: require('./page1.html'),
            controller: function ($http) {
                this.title = 'This is page 1';
                $http.get('/getCountryList').then(function (res) {
                    console.log(res);
                })
            },
            controllerAs: 'test'
        }).state('feng.page2', {
            url: '/page2',
            template: require('./page2.html'),
            controller: function ($scope) {
                this.title = 'This is page 2';
                $scope.firstBox = new Array(7);
                $scope.secondBox = new Array(7);
                $scope.thirdBox = new Array(6);
            },
            controllerAs: 'test'
        }).state('feng.page3', {
            url: '/page3',
            template: require('./page3/page3.html'),
            controller: 'page3Ctrl',
            controllerAs: 'test'
        }).state('feng.page5', {
            url: '/page5',
            template: require('./module/page5/page5.html'),
            controller: 'page5Ctrl',
            controllerAs: 'test'
        }).state('feng.selfService', {
            url: '/self-service',
            template: require('./module/selfService/selfService.html'),
            controller: 'selfServiceCtrl',
            controllerAs: 'test'
        });
    }]);
    var ON_DEMO = true
    if (ON_DEMO) {
        ngModule.config(['$stateProvider', '$locationProvider', '$urlRouterProvider', function ($stateProvider, $locationProvider, $urlRouterProvider) {
            $stateProvider.state('feng.page4', {
                url: '/page4',
                templateProvider: ['$q', function ($q) {
                    let deferred = $q.defer();
                    require.ensure(['./page4/page4.html'], function () {
                        let template = require('./page4/page4.html');
                        deferred.resolve(template);
                    });
                    return deferred.promise;
                }],
                controller: 'Page4Controller',
                controllerAs: 'test',
                resolve: {
                    foo: ['$q', '$ocLazyLoad', function ($q, $ocLazyLoad) {
                        let deferred = $q.defer();
                        require.ensure([], function () {
                            page4Fn(Angular)
                            $ocLazyLoad.load({
                                name: 'page4App'
                            });
                            deferred.resolve();
                        });
                        return deferred.promise;
                    }]
                }
            });
        }]);

    }
    layerApp(ngModule, Angular);
    // ueditorApp(ngModule, Angular);
    graphApp(ngModule, Angular);
    lineApp(ngModule, Angular);
    ztreeApp(ngModule, Angular);
    formApp(ngModule, Angular);
    circleApp(ngModule, Angular);
    radarApp(ngModule, Angular);
    selfTable(ngModule, Angular);
    ngRepeat(ngModule, Angular);
    timeLine(ngModule, Angular);
}